Completed
Push — master ( e3ee1d...5cbb1b )
by Justin
01:36
created

Person.js ➔ describe(ꞌPersonꞌ)   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 102

Duplication

Lines 102
Ratio 100 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
nc 1
nop 0
dl 102
loc 102
rs 8.2857

3 Functions

Rating   Name   Duplication   Size   Complexity  
B Person.js ➔ ... ➔ it(ꞌCreate with JSONꞌ) 43 43 1
B Person.js ➔ ... ➔ it(ꞌtoJSONꞌ) 35 35 1
A Person.js ➔ ... ➔ it(ꞌBuildꞌ) 18 18 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1 View Code Duplication
var assert = require('chai').assert,
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated in your project.
Loading history...
2
    GedcomX = require('../../');
3
4
describe('Person', function(){
5
  
6
  it('Create with JSON', function(){
7
    var person = GedcomX.Person({
8
      id: 'testPerson',
9
      private: true,
10
      living: true,
11
      gender: {
12
        type: 'http://gedcomx.org/Female'
13
      },
14
      names: [
15
        {
16
          type: 'http://gedcomx.org/BirthName',
17
          nameForms: [
18
            {
19
              fullText: 'Joanna Hopkins'
20
            }
21
          ]
22
        }  
23
      ],
24
      facts: [
25
        {
26
          type: 'http://gedcomx.org/Birth',
27
          date: {
28
            formal: '+2001-04-09'
29
          },
30
          place: {
31
            original: 'Farm house'
32
          }
33
        }  
34
      ],
35
      display: {
36
        "name" : "Joanna Hopkins",
37
        "gender" : "Female"
38
      }
39
    });
40
    assert.equal(person.getLiving(), true);
41
    assert.equal(person.getId(), 'testPerson');
42
    assert.equal(person.getPrivate(), true);
43
    assert.equal(person.getGender().getType(), 'http://gedcomx.org/Female');
44
    assert.equal(person.getNames()[0].getNameForms()[0].getFullText(), 'Joanna Hopkins');
45
    assert.equal(person.getFacts()[0].getDate().getFormal(), '+2001-04-09');
46
    assert.equal(person.getFacts()[0].getPlace().getOriginal(), 'Farm house');
47
    assert.equal(person.getDisplay().getName(), 'Joanna Hopkins');
48
  });
49
  
50
  it('Build', function(){
51
    var person = GedcomX.Person()
52
      .setId('testPerson')
53
      .setLiving(true)
54
      .setPrivate(true)
55
      .setGender(GedcomX.Gender().setType('http://gedcomx.org/Female'))
56
      .addName(GedcomX.Name().addNameForm(GedcomX.NameForm().setFullText('Joanna Hopkins')))
57
      .addFact(GedcomX.Fact().setDate(GedcomX.Date().setFormal('+2001-04-09')).setPlace(GedcomX.PlaceReference().setOriginal('Farm house')))
58
      .setDisplay(GedcomX.DisplayProperties().setName("Joanna Hopkins").setGender("Female"));
59
    assert.equal(person.getLiving(), true);
60
    assert.equal(person.getId(), 'testPerson');
61
    assert.equal(person.getPrivate(), true);
62
    assert.equal(person.getGender().getType(), 'http://gedcomx.org/Female');
63
    assert.equal(person.getNames()[0].getNameForms()[0].getFullText(), 'Joanna Hopkins');
64
    assert.equal(person.getFacts()[0].getDate().getFormal(), '+2001-04-09');
65
    assert.equal(person.getFacts()[0].getPlace().getOriginal(), 'Farm house');
66
    assert.equal(person.getDisplay().getName(), 'Joanna Hopkins');
67
  });
68
  
69
  it('toJSON', function(){
70
    var data = {
71
      id: 'testPerson',
72
      private: true,
73
      gender: {
74
        type: 'http://gedcomx.org/Female'
75
      },
76
      names: [
77
        {
78
          type: 'http://gedcomx.org/BirthName',
79
          nameForms: [
80
            {
81
              fullText: 'Joanna Hopkins'
82
            }
83
          ]
84
        }  
85
      ],
86
      facts: [
87
        {
88
          type: 'http://gedcomx.org/Birth',
89
          date: {
90
            formal: '+2001-04-09'
91
          },
92
          place: {
93
            original: 'Farm house'
94
          }
95
        }  
96
      ],
97
      display: {
98
        "name" : "Joanna Hopkins",
99
        "gender" : "Female"
100
      }
101
    }, person = GedcomX.Person(data);
102
    assert.deepEqual(person.toJSON(), data);
103
  });
104
  
105
});